> ?wilcox.test > x <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30) > y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29) > wilcox.test(x, y, paired = TRUE, alternative = "greater") Wilcoxon signed rank test data: x and y V = 40, p-value = 0.01953 alternative hypothesis: true location shift is greater than 0 > wilcox.test(x, y, paired = TRUE) Wilcoxon signed rank test data: x and y V = 40, p-value = 0.03906 alternative hypothesis: true location shift is not equal to 0 > wilcox.test(x, y) Wilcoxon rank sum test with continuity correction data: x and y W = 58, p-value = 0.1329 alternative hypothesis: true location shift is not equal to 0 Warning message: In wilcox.test.default(x, y) : cannot compute exact p-value with ties ---------------------------------------------------------------------- > v1 <- rnorm(100) > v2 <- rnorm(100, mean=3) > v3 <- rnorm(100, mean=3, sd=5) > boxplot(v1, v2, v3) > par(mfrow=c(3,1)) > hist(v1) > hist(v2) > hist(v3) ---------------------------------------------------------------------- > x <- c(NA, 3, 4, 5, NA) > y <- c(1, 2, NA, 3, 4) > !is.na(x & y) [1] FALSE TRUE FALSE TRUE FALSE > 1+NA [1] NA > !is.na(x + y) [1] FALSE TRUE FALSE TRUE FALSE > !is.na(x) & !is.na(y) [1] FALSE TRUE FALSE TRUE FALSE > mean function (x, ...) UseMethod("mean") > sum function (..., na.rm = FALSE) .Primitive("sum") > c function (..., recursive = FALSE) .Primitive("c") > f <- function(x) x^2 > f(2) [1] 4 > m <- function(a, b) { + if (a < b) + b + else + a + } > m(1, 2) [1] 2 > s <- function(v) { + sum <- 0 + for (x in v) + sum <- sum + x + } > s(1:3) > x <- s(1:3) > x NULL > fix(s) > s function(v) { sum <- 0 for (x in v) sum <- sum + x return(sum) } > s(1:3) [1] 6 > fix(s) > s function(v) { sum <- 0 for (x in v) sum <- sum + x return(sum) } > sum function (..., na.rm = FALSE) .Primitive("sum") > inc <- function(x, by=1) x + by > inc function(x, by=1) x + by > inc(1) [1] 2 > inc(1, by=10) [1] 11 > inc(by=10, 1) [1] 11 > plot(1:10) > > plot(1:10) > plot(1:10, main="my title") > function(x) x^2 function(x) x^2 > sum function (..., na.rm = FALSE) .Primitive("sum") > c function (..., recursive = FALSE) .Primitive("c") > c(1, 2, 3, 34) [1] 1 2 3 34 > c(1, 2, 3, 34, 4, 4) [1] 1 2 3 34 4 4 > ?plot > ls() [1] "f" "inc" "m" "s" "v" "v2" "v3" "x" [9] "y" > function(x) x^2 function(x) x^2 > f function(x) x^2 > x <- 1 > f(2) [1] 4 > f <- function(x) { + x <- 2 + } > x [1] 1 > f(1) > x [1] 1 > f <- function(x) { + x <<- 2 + } > f() > x [1] 2 > x <- 1 > f <- function(y) x + y > f(1) [1] 2 >